module AsadoL (Asado, prenderElFuego, agregar, sacar, sacarN, hay)
where

import Corte

data Asado = ColocarEnParrilla [Corte]

instance Show Asado where
	show (ColocarEnParrilla xs) = show xs

prenderElFuego :: Asado
prenderElFuego = ColocarEnParrilla []

agregar :: Corte -> Asado -> Asado
agregar c (ColocarEnParrilla xs) = ColocarEnParrilla (c:xs)

hay :: Corte -> Asado -> Bool
hay c (ColocarEnParrilla []) == False
hay c (ColocarEnParrilla (x:xs)) = x == c || hay c (ColocarEnParrilla xs) 


sacar :: Corte -> Asado -> Asado
sacar c (ColocarEnParrilla (x:xs)) | c == x = sacar c (ColocarEnParrilla xs)
                                   | otherwise = agregar x (sacar c (ColocarEnParrilla xs))


-- requiere cantDeCorte(c,a) > n
sacarN :: Int -> Corte -> Asado -> Asado
sacarN 0 c a = a
sacarN n c (ColocarEnParrilla (x:xs)) | c == x = sacarN (n-1) c (ColocarEnParrilla xs)
                                      | otherwise = agregar x (sacarN (n-1) c (ColocarEnParrilla (x:xs)))


